You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Budget-exhausted turns now surface as visibly incomplete instead of letting a fluent model summary pass as a verified final answer. Both max_iterations and shared IterationBudget exhaustion return completed=false with structured budget metadata, and the final visible response is wrapped in runtime-owned wording that says the task is not verified complete and can be resumed with continue.
This keeps downstream behavior honest without introducing startup-context optimization or a new resume system: gateway resume markers stay uncleared, cron treats the run as failed, and final-send suppression no longer hides the deterministic incomplete-state warning after streamed/interim content.
Design notes
Concern
Decision
Completion truth
budget_exhausted=true, failure_reason="budget_exhausted", budget_used, and budget_max are emitted on every finalizer result.
User-facing response
Model-authored summary text is demoted under “Progress summary from the model”; runtime wording remains the completion authority.
Gateway delivery
Budget-exhausted responses bypass normal “already streamed” suppression so the warning reaches chat even after interim content.
Scope discipline
The budget fix is independent of startup context audit code/config and does not add provider/model or auto-resume behavior.
Validation window: first 24 hours after deployment; owner: Hermes ops.
Healthy signals: exhausted turns include budget_exhausted=true, completed=false, and user-visible text starting with Iteration budget exhausted; cron runs with exhausted budgets record failure rather than ok.
Log checks: search gateway/agent logs for iteration_budget_exhausted, max_iterations_reached, budget_exhausted, and Suppressing normal final send around exhausted turns.
Failure signals: budget-exhausted turns marked completed=true, cron jobs marked successful after exhausted turns, or chat users receiving only interim/tool-progress text without the deterministic warning.
Rollback trigger: any increase in normal successful turns receiving budget warnings, or plugin/gateway delivery errors caused by the new result metadata.
Thanks @spiky02plateau. The core data-loss in #8049 is now fixed on main via #50009 (merge commit 9f67ba1): the unguarded cleanup chain in finalize_turn no longer lets a trajectory/resource/SQLite failure escape run_conversation and discard the partial response.
This PR goes considerably further than the reported bug — ~670 lines reworking completion semantics (budget_exhausted metadata, runtime-owned "incomplete" wording, gateway final-send suppression bypass, cron PARTIAL handling). That's a meaningful design direction, but it's a separate feature from the silent-exit fix #8049 asked for, and it doesn't itself guard the cleanup chain. We'd rather not couple the budget-completion-truth redesign to this P1 bug.
Closing against #8049 since the data-loss is resolved. If you want to pursue the "visibly incomplete budget" behavior, please open a focused PR scoped to just that and we'll review it on its own merits — thanks for the thorough write-up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointP1High — major feature broken, no workaroundtype/bugSomething isn't working
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Budget-exhausted turns now surface as visibly incomplete instead of letting a fluent model summary pass as a verified final answer. Both
max_iterationsand sharedIterationBudgetexhaustion returncompleted=falsewith structured budget metadata, and the final visible response is wrapped in runtime-owned wording that says the task is not verified complete and can be resumed withcontinue.This keeps downstream behavior honest without introducing startup-context optimization or a new resume system: gateway resume markers stay uncleared, cron treats the run as failed, and final-send suppression no longer hides the deterministic incomplete-state warning after streamed/interim content.
Design notes
budget_exhausted=true,failure_reason="budget_exhausted",budget_used, andbudget_maxare emitted on every finalizer result.Tests
python -m pytest tests/agent/test_turn_finalizer_budget_exhaustion.py tests/run_agent/test_turn_completion_explainer.py tests/gateway/test_restart_resume_pending.py tests/cron/test_scheduler.py -q -o 'addopts='python -m py_compile agent/turn_finalizer.py agent/chat_completion_helpers.py gateway/run.py run_agent.py tests/agent/test_turn_finalizer_budget_exhaustion.py tests/run_agent/test_turn_completion_explainer.py tests/gateway/test_restart_resume_pending.py tests/cron/test_scheduler.pyPost-Deploy Monitoring & Validation
budget_exhausted=true,completed=false, and user-visible text starting withIteration budget exhausted; cron runs with exhausted budgets record failure rather thanok.iteration_budget_exhausted,max_iterations_reached,budget_exhausted, andSuppressing normal final sendaround exhausted turns.completed=true, cron jobs marked successful after exhausted turns, or chat users receiving only interim/tool-progress text without the deterministic warning.